package Proxy

class CandyMachine {
  private var state: State = new OnReadyState(this)
  private var count: Int = _
  val mSoldOutState = new SoldOutState(this)
  val mOnReadyState = new OnReadyState(this)
  val mSoldingState = new SoldingState(this)
  private var location: String = _

  def this(location: String, count: Int) {
    this
    this.location = location
    this.count = count
  }

  def setState(sta: State): Unit = {
    this.state = sta
  }

  def getState = this.state

  def releaseCandy(): Unit = {
    this.count -= 1
  }

  def getCount(): Int = {
    this.count
  }

  def getLocaltion() = {
    this.location
  }

  def insertCoin(): Unit = {
    this.count += 1
  }

  def turnCrank() {}

}
